<template>
  <div id="detail">
    <van-nav-bar title="新闻内容">
      <template #left>
        <van-icon name="revoke" size="20" @click="back" />
      </template>
      <template #right>
        <van-icon name="search" size="20" />
      </template>
    </van-nav-bar>
    <div id="content">
      <van-image
        width="100%"
        height="100%"
        :src="this.IMGURL+newDetail.img"
      />
      <h2>{{newDetail.title}}</h2>
      <van-row>
        <van-col span="16">创建时间：{{newDetail.create_time}}</van-col>
        <van-col span="8">分类：{{newDetail.type}}</van-col>
      </van-row>
      <p v-html="newDetail.content"></p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      newDetail:{}
    };
  },
  computed: {
    newsId() {
      return this.$route.params.id;
    },
  },
  created() {
    this.getNewsDetail();
  },
  methods: {
    async getNewsDetail() {
      const { data: res } = await this.$http.get(
        this.HOST + "news/getnewsdetail?id=" + this.newsId
      );
      switch(res.data[0].type_id){
        case 1:
          res.data[0].type='平台时讯'
          break
        case 2:
          res.data[0].type='创业经验'
          break
        case 3:
          res.data[0].type='优质加盟'
          break
        case 4:
          res.data[0].type='熊熊乐园'
          break
      }
        
      this.newDetail=res.data[0]
      console.log(this.newDetail)
    },
    back() {
      history.go(-1);
    },
  },
};
</script>

<style lang="scss" scoped>
header > img {
  width: 50px;
  height: 50px;
}
</style>